package com.jrx.anytxn.investor.service;

import com.jrx.anytxn.common.exception.TxnBizException;
import com.jrx.anytxn.common.exception.TxnException;
import com.jrx.anytxn.customer.dto.customer.CustomerRes;
import com.jrx.anytxn.feign.gateway.bean.ApiResponse;
import com.jrx.anytxn.feign.gateway.response.CoreResponse04;
import com.jrx.anytxn.feign.gateway.response.CoreResponse09;
import com.jrx.anytxn.investor.entity.*;
import com.jrx.anytxn.param.entity.PrInvestorTable;
import com.jrx.anytxn.transaction.entity.AmLoanMainInfo;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * 客户出资方放款Service接口
 *
 * @author liuyang
 * @date 2020-06-16
 */
public interface IInvestorLoanService {

    /**
     * 构建资金限制流水
     *
     * @param investorTable 出资方信息
     * @param fundRouteLog  资金源路由记录
     * @param amount        交易金额
     * @param fundId        资金源id
     * @param restraintType 限制类型
     * @param businessDate  业务日期
     * @param restraintNo   限制编号
     * @return TlFundRestraintLog 资金限制流水
     * @throws TxnBizException
     * @author liuyang
     * @date 2020-06-16
     */
    TlFundRestraintLog buildTlFundRestraintLog(PrInvestorTable investorTable, TlFundRouteLog fundRouteLog, BigDecimal amount, String fundId, String restraintType, Date businessDate, String restraintNo) throws TxnBizException;

    /**
     * 构建限制流水
     *
     * @param fundRestraintLog 原限制流水
     * @param restraintType    限制类型
     * @param restraintNo      限制编号
     * @return
     * @throws TxnBizException
     */
    TlFundRestraintLog buildTlFundRestraintLog(TlFundRestraintLog fundRestraintLog, String restraintType, String restraintNo) throws TxnBizException;

    /**
     * 构建放款出资方审批记录
     *
     * @param fundRouteLog  资金源路由记录
     * @param customerRes   客户信息
     * @param investorId    出资方id
     * @param loanAmount    借款金额
     * @param fundId        资金源id
     * @param routeOrder    路由顺序
     * @param resultMessage 结果信息
     * @return TlInvestorLoanApproveLog 放款出资方审批记录
     * @throws TxnBizException
     * @author liuyang
     * @date 2020-06-16
     */
    TlInvestorLoanApproveLog buildTlInvestorLoanApproveLog(TlFundRouteLog fundRouteLog, CustomerRes customerRes, String investorId, BigDecimal loanAmount, String fundId, Integer routeOrder, String resultMessage) throws TxnBizException;

    /**
     * 构建资金转账流水
     *
     * @param loanMainInfo 对客订单
     * @param seqNo        交易流水号
     * @param businessDate 业务日期
     * @param transferType 转账类型
     * @return TlFundTransferLog 资金转账流水
     * @throws TxnBizException
     * @author liuyang
     * @date 2020-06-16
     */
    TlFundTransferLog buildTlFundTransferLog(AmLoanMainInfo loanMainInfo, String seqNo, Date businessDate, String transferType) throws TxnBizException;

    /**
     * 构建资金转账明细
     *
     * @param fundRestraintLogs 资金源限制流水
     * @param fundTransferLog   转账记录
     * @param currency          币种
     * @param investorIds       出资方id
     * @param bankLoanAmount    本行借款金额
     * @return List<TlFundTransferDetail> 资金转账明细
     * @throws TxnBizException
     */
    List<TlFundTransferDetail> buildTlFundTransferDetails(List<TlFundRestraintLog> fundRestraintLogs, TlFundTransferLog fundTransferLog, String currency, Set<String> investorIds, BigDecimal bankLoanAmount) throws TxnException;

    /**
     * 构建资金转账流水
     *
     * @param origFundTransferLog 原资金转账流水
     * @param businessDate        业务日期
     * @param transferType        转账类型
     * @return TlFundTransferLog 资金转账流水
     * @throws TxnBizException
     * @author liuyang
     * @date 2020-06-17
     */
    TlFundTransferLog buildTlFundTransferLog(TlFundTransferLog origFundTransferLog, Date businessDate, String transferType) throws TxnBizException;

}
